package com.heeexy.example.controller.web;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.heeexy.example.service.ActiceService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import yinwei.bo.common.entry.actice;
import yinwei.bo.common.result.R;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("actice")
public class ActiceController {

    @Resource
    private ActiceService acticeService;

    @RequestMapping("getList")
    public R findActice(@RequestParam(defaultValue = "1") Integer CurrentPage,
                        @RequestParam(defaultValue = "10") Integer PageSize){
       List<actice> list=acticeService.findActice();
        PageHelper.offsetPage((CurrentPage - 1) * PageSize,PageSize);
        PageInfo pageInfo = new PageInfo(list);
        Map map=new HashMap();
        map.put("list",pageInfo);
        return R.ok().data(map);
    }

    @RequestMapping("getActiceById")
    public R findActiceById(Integer id){
        System.out.println(id);
        actice actice=acticeService.findActiceById(id);
        Map map=new HashMap();
        map.put("list",actice);
        return R.ok().data(map);
    }

}
